package com.ldcc.report_system.util;

import android.content.res.Resources;
import android.graphics.Color;
import android.view.View;
import android.view.Window;

import com.ldcc.report_system.ReportApplication;

/**
 * @author wwj[yeshengkele@outlool.com]
 * @description 界面处理工具类
 */
public class WindowUtils {

    /**
     * @return 获取状态栏高度
     */
    public static int getStatusBarHeight() {
        Resources resources = ReportApplication.getContext().getResources();
        int result = 0;
        //获取状态栏高度的资源id
        int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            result = resources.getDimensionPixelSize(resourceId);
        }
        return result;
    }

    /**
     * @param window windows对象
     * @description 设置
     */
    public static void setWindowTopTransparent(Window window) {
        //设置状态栏和导航栏颜色为透明
        View decorView = window.getDecorView();
        // SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 把布局拓展到通知栏后面
        int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(option);
        //设置通知栏颜色为透明
        window.setStatusBarColor(Color.TRANSPARENT);
    }

}
